#include "StdAfx.h"
#include "UnitTest++.h"

#include "Resource.h"

//////////////////////////////////////////////////
//ResourceTest
//////////////////////////////////////////////////

TEST(TestResourceConstructor)
  {
  Resource<int> resource("c:\\test\\", "name");
  CHECK_EQUAL(resource.GetPath(), "c:\\test\\");
  CHECK_EQUAL(resource.GetName(), "name");
  CHECK_EQUAL(resource.GetFilename(), "c:\\test\\name");
  CHECK_EQUAL(resource.GetNbOfReferences(), 1);
  }

//------------------------------------------------

TEST(TestResourceReference)
  {
  Resource<int> resource("c:\\test\\", "name");
  CHECK_EQUAL(resource.GetNbOfReferences(), 1);  
  resource.AddReference();
  CHECK_EQUAL(resource.GetNbOfReferences(), 2);
  resource.AddReference();
  CHECK_EQUAL(resource.GetNbOfReferences(), 3);
  resource.RemoveReference();
  CHECK_EQUAL(resource.GetNbOfReferences(), 2);
  resource.RemoveReference();
  CHECK_EQUAL(resource.GetNbOfReferences(), 1);
  resource.RemoveReference();
  CHECK_EQUAL(resource.GetNbOfReferences(), 0);  
  }

//------------------------------------------------

//////////////////////////////////////////////////